package org.example.qo;

import lombok.*;

import java.util.List;

/**
 * @author 李新雨的项目86176
 * @version 1.0
 * @date 2024-11-30 20:33
 */
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Setter
@Getter
public class PageResult<T> {
    private int currentPage;//当前页
    private int pageSize;//每页的条数
    private int totalCount;//总数据条数
    private List<T> data;//每页的数据
    private int totalPage;//总页数
    private int prevPage;//上一页
    private int nextPage;//下



    /**
     * // TODO: 2024/11/30 为啥     -----
     * @param currentPage
     * @param pageSize
     * @param totalCount
     * @param data
     */
    public PageResult(int currentPage, int pageSize, int totalCount, List<T> data) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.data = data;
         totalPage=this.totalCount%this.pageSize==0?(this.totalCount/this.pageSize):(totalCount/this.pageSize+1);
         prevPage=this.currentPage-1>=1?(this.currentPage-1):1;
         nextPage=this.currentPage+1<=this.totalPage?this.currentPage+1:totalPage;

    }
}
